﻿using FluffyUnderware.Curvy;
using NodeCanvas.StateMachines;
using System;
using System.Collections;
using System.Collections.Generic;
using com.yoozoo.gta.Gameplay.City.AI;
using UnityEngine;
using XLua;
using Yoozoo.Core.PathFinder;
using yoozoo.Gameplay.City.AI;
using Yoozoo.Gameplay.City.AI;

namespace Yoozoo.Gameplay.City
{
    public class CityAIManager
    {
        public static CityAIManager Instance;
        
        private Transform FreeAIRoot;
        [BlackList]
        public CityAIManager()
        {
            Instance = this;
        }

        public float deltaTime;
        public float clientTime;
        private float _lastClientTime;
        [BlackList]
        public void Update()
        {
            clientTime = TimeUtils.GetClientTickTime();
            deltaTime = 0;
            if (_lastClientTime > 0)
            {
                deltaTime = clientTime - _lastClientTime;  //TODO: 这个有点问题吧？,
                if (deltaTime > 1)
                {
                    deltaTime = 0;
                }
            }
            else
            {
                deltaTime = Time.deltaTime;
            }
            _lastClientTime = clientTime;
            FreeAIDataManager.Instance.Update(clientTime,deltaTime);
        }
        
        private FreeAIEntity CreateNewFreeAIEntity()
        {
            var gameObject = new GameObject();
            var freeAIEntity = new FreeAIEntity();
            var freeAIMono = gameObject.AddComponent<FreeAIMono>();
            freeAIEntity.Mono = freeAIMono;
            //gameObject.transform.SetParent(isMonster == false ? marchEntityRoot: monsterEntityRoot);
            freeAIMono.enabled = false;
            return freeAIEntity;
        }
        
    }

}
